<?php

class Animal {
    public $name = 'Animal';
    public function shout(){
        echo '动物叫';
    }
}

class Animal1 {
    public $name = 'Animal';
    private $age = 10;//私有属性和方法不会被继承
    public function __construct($name = 'Animal')
    {
        echo '父类的构造方法被调用了'.'<br>';
        $this->name = $name;
    }
    public function shout(){
        echo '动物叫';
    }
}

/**
 * php继承的语法
 * 子类extends 父类{...}
 */

 class Dog extends Animal{
    public $owner = 'Lisi';

    public function shout(){
        echo '狗叫';
    }

    public function swim(){
        echo '狗会游泳';
    }
 }

 class Dog1 extends Animal1{
    public $owner = 'Lisi';
 }




 $dog = new Dog();
 echo $dog->name.'<br>';
 echo $dog->owner.'<br>';
 echo $dog->shout().'<br>';
 echo $dog->swim().'<br>';

 $dog1 = new Dog1('BigDog');
 echo $dog1->name.'<br>';
 echo $dog1->age.'<br>';
